<div class="deal">
<div class="deal_content_top"></div>
<div class="deal_content">
<h3>Thống kê deal</h3>

<div align="center" style="background-color: white;">
	<form action="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>" method="get">
		<table>
			<tr>
				<td><strong>Tìm kiếm</strong></td>
				<td>
					<input type="text" name="filter" value="<?php if(isset($this->filter)) echo $this->filter; ?>" />
				</td>
				<td>
					<input type="submit" value="Tìm" />
				</td>
			</tr>
		</table>
	</form>
</div>

<table class="table-style" style="width: 100%;" cellpadding="5px"
	cellspacing="0">
	<tbody>
		<tr class="table-title">
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=b.deal_id&order=<?php echo ($this->by != "b.deal_id" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">ID</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=b.deal_title&order=<?php echo ($this->by != "b.deal_title" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Tên</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=b.deadline&order=<?php echo ($this->by != "b.deadline" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Thời hạn</a></td>
			<td><a href="#">Trạng thái</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=b.created&order=<?php echo ($this->by != "b.created" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Ngày tạo</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=b.deadline&order=<?php echo ($this->by != "b.deadline" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Ngày hết hạn</a></td>
			<td><a href="<?php echo $this->baseUrl("index.php/admin_cms/dealstatistics") ?>?by=count_deal&order=<?php echo ($this->by != "count_deal" || $this->order == "desc") ? "asc" : "desc"; ?><?php if($this->filter != "") echo "&filter=".$this->filter; ?>">Số lượng mua</a></td>
			<td>&nbsp;</td>
		</tr>
		<?php
		if (count($this->paginator) == 0) {
			echo "<tr><td colspan='3' align='center'>No deal</td></tr>";
		} else {
			?>
			<?php $i = 0 ?>
			<?php foreach ($this->paginator as $deal): ?>
			<?php $i++ ?>
		<tr class="<?php echo $i % 2 == 0 ? 'even' : 'odd' ?>">
			<td><?php echo $deal->deal_id ?></td>
			<td>
				<a href="<?php echo $this->baseUrl('index.php/cms/index/deal/id/') . $deal->deal_id ?>"><?php echo $deal->deal_title ?></a>
			</td>
			<td>
				<?php
				if(strcmp($deal->deadline, date("Y-m-d")) < 0)
				{
					echo "Hết hạn";
				}
				else
				{
					echo "Còn hạn";
				}
				?>
			</td>
			<td>
				<?php
				if($deal->deal_quantity <= $deal->count_deal)
				{
					echo "Đạt giá tốt";
				}
				else
				{
					echo "Chưa đạt giá tốt";
				}
				?>
			</td>
			<td><?php echo substr($deal->created, 0, 10) ?></td>
			<td><?php echo substr($deal->deadline, 0, 10) ?></td>
			<td><?php echo $deal->count_deal ?></td>
		</tr>
		<?php endforeach ?>
		<?php } ?>
	</tbody>
</table>
		
<?php echo $this->paginator; ?>
</div>

<div class="deal_content_bottom"></div>
</div>
